package com.superquan.selfstudybootmybatis.utils.gather;

import com.superquan.selfstudybootmybatis.entity.user.People;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.List;

@SpringBootTest
public class GatherTest {

    @Test
    public void uniqListByStream(){
        List<String> list = new ArrayList<>();
        list.add("1");
        list.add("4");
        list.add("9");
        list.add("3");
        list.add("4");
        List<String> uniqList = GatherUtil.uniqListByStream(list);
//        uniqList.stream().sorted();
        System.out.println(uniqList.toString());
    }

    @Test
    public void uniqListByStream2(){
        List<People> list1=new ArrayList<>();
        list1.add(new People(1,"jack",12,1));
        list1.add(new People(2,"alice",16,0));
        list1.add(new People(3,"ryan",18,1));
        list1.add(new People(2,"alice",16,0));
        list1.add(new People(4,"bob",18,1));
        List<People> peopleList = GatherUtil.uniqListByStream2(list1);
        peopleList.forEach(people -> {
            System.out.println(people.toString());
        });
    }

    @Test
    public void insertMiddle(){
        List<String> list2=new ArrayList<>();
        list2.add("1");
        list2.add("2");
        list2.add("3");
        list2.add("4");
        list2.add("5");
        list2.add("6");
        GatherUtil.insertMiddle(list2,"88");
    }
}
